package jpa.Model;

import javax.persistence.*;
import java.util.Set;

/**
 * Created by IntelliJ IDEA.
 * User: Pavlo
 * Date: 30.01.12
 * Time: 16:22
 * To change this template use File | Settings | File Templates.
 */
@Entity
@Table(name = "Candidate")
public class Candidate extends ID{

    private String name;

    private CandidateType type;

    private Set<VoteResult> voteResults;

    @Column(name = "name", nullable = false, unique = false)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @ManyToOne
    @JoinColumn(name = "type", referencedColumnName = "ID")
    public CandidateType getType() {
        return type;
    }

    public void setType(CandidateType type) {
        this.type = type;
    }

    @OneToMany
    @JoinColumn(name = "candidate")
    public Set<VoteResult> getVoteResults() {
        return voteResults;
    }

    public void setVoteResults(Set<VoteResult> voteResults) {
        this.voteResults = voteResults;
    }
}
